home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.02 Feb 93 / Screen I⁄O Classes / B Classes / B.c / BDisplayOutput.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-12  |  3.6 KB  |  156 lines  |  [TEXT/KAHL]

  1. /**************************************************************
  2.  * BDisplayOutput.c
  3.  *
  4.  * SUPERCLASS = BEditDoc
  5.  *
  6.  * Display the contents of a Handle in a text screen.  It requires
  7.  *   a floating window desktop
  8.  * Window resource with id of 500 must be in resource file.
  9.  *
  10.  * © copyright 1991, KSS Scientific Consultants.
  11.  *
  12.  **************************************************************/
  13.  
  14. #include <CApplication.h>
  15. #include <CBureaucrat.h>
  16. #include <CScrollPane.h>
  17. #include <CSwitchboard.h>
  18. #include <CWindow.h>
  19. #include <string.h>
  20. #include "BDisplayOutput.h"
  21. #include "BEditPane.h"
  22.  
  23. #define    WINDculture        500        // Resource ID for WIND template
  24.  
  25. extern CApplication        *gApplication;
  26. extern CBureaucrat        *gGopher;
  27. extern CDesktop            *gDesktop;            // The visible Desktop
  28. //Boolean        BDisplayOutput::fQuitStatus = FALSE;
  29.  
  30. /*****************************************************************
  31.  * IBDisplayOutput()
  32.  *
  33.  * Initialization method.
  34.  *
  35.  ****************************************************************/
  36.     
  37. void BDisplayOutput::IBDisplayOutput(CApplication *anApplication, Boolean printable)
  38. {
  39.     inherited::IEditDoc(anApplication, printable);
  40. }
  41.  
  42. /******************************************************************
  43.  * BuildWindow
  44.  *
  45.  * Override BuildWindow so a floating window is created and it is 
  46.  *   not positioned by the Decorator.
  47.  *
  48.  *******************************************************************/
  49.  
  50. void BDisplayOutput::BuildWindow (Handle theData)
  51.  
  52. {
  53.     CScrollPane        *theScrollPane;
  54.     BEditPane        *theMainPane;
  55.     Rect            margin;
  56.  
  57.     itsWindow = new(CWindow);
  58.     itsWindow->IWindow(WINDculture, TRUE, gDesktop, this);
  59.     itsWindow->Move(40, 60);
  60.     
  61.     theScrollPane = new(CScrollPane);
  62.     
  63.     theScrollPane->IScrollPane(itsWindow, this, 10, 10, 0, 0,
  64.                                 sizELASTIC, sizELASTIC,
  65.                                 TRUE, TRUE, TRUE);
  66.  
  67.     theScrollPane->FitToEnclFrame(TRUE, TRUE);
  68.  
  69.     theMainPane = new(BEditPane);
  70.     itsMainPane = theMainPane;
  71.     itsGopher = theMainPane;
  72.  
  73.     theMainPane->IEditPane(theScrollPane, this);
  74.  
  75.     theScrollPane->InstallPanorama(theMainPane);
  76.  
  77.     if (theData)
  78.         theMainPane->SetTextHandle(theData);
  79.     
  80.     //gDecorator->PlaceNewWindow(itsWindow);
  81. }
  82.  
  83. /**********************************************************
  84.  * EventManagement()
  85.  *
  86.  * Event control loop
  87.  *
  88.  **********************************************************/
  89.  
  90. void BDisplayOutput::EventManagement(void)
  91. {
  92.     SetQuitStatus(FALSE);
  93.     do
  94.     {
  95.         gApplication->itsSwitchboard->ProcessEvent();
  96.     } while (GetQuitStatus() == FALSE);
  97. }
  98.  
  99. /*****************************************************************
  100.  * DisplayRun()
  101.  *
  102.  * Entry method.
  103.  *
  104.  ****************************************************************/
  105.     
  106. void BDisplayOutput::DisplayRun(Handle theText)
  107. {
  108.     long    tempLong;
  109.     
  110.     BuildWindow(0L);
  111.     itsWindow->Select();
  112.  
  113.     tempLong = strlen(*theText);
  114.     SetHandleSize(theText, tempLong);
  115.     ((BEditPane*)itsMainPane)->SetTextHandle(theText);
  116.     
  117.     EventManagement();
  118.     
  119. }
  120.  
  121. /********************************************************************
  122.  * CloseWind()
  123.  *
  124.  * Add code to change QuitStatus to TRUE
  125.  *
  126.  ********************************************************************/
  127.  
  128. void BDisplayOutput::CloseWind(CWindow *theWindow)
  129. {
  130.     SetQuitStatus(TRUE);
  131.     
  132. }
  133.  
  134. /**********************************************************************
  135.  * SetQuitStatus()
  136.  *
  137.  * Set or reset fQuitStatus.
  138.  *
  139.  *********************************************************************/
  140.  
  141. void BDisplayOutput::SetQuitStatus(Boolean status)
  142. {
  143.     fQuitStatus = status;
  144. }
  145.  
  146. /**********************************************************************
  147.  * GetQuitStatus()
  148.  *
  149.  * Get the status fQuitStatus.
  150.  *
  151.  **********************************************************************/
  152.  
  153. Boolean BDisplayOutput::GetQuitStatus(void)
  154. {
  155.     return (fQuitStatus);
  156. }